﻿using QL_DTTN.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QL_DTTN.DTO.DTO
{
   public partial class TaiKhoan
    {
       public  TaiKhoan GetTaiKhoan(string tenTaiKhoan)
       {
           bool kt = false;
           SqlDataProvider dp = new SqlDataProvider();
           System.Data.SqlClient.SqlDataReader sqlRr = GetObject(tenTaiKhoan, dp);
           TaiKhoan tk = new TaiKhoan();
           if (sqlRr != null)
           {
               while (sqlRr.Read())
               {
                   if (!Convert.IsDBNull(sqlRr["TenTaiKhoan"])) tk.TenTaiKhoan = sqlRr["TenTaiKhoan"].ToString();
                   if (!Convert.IsDBNull(sqlRr["MatKhau"])) tk.MatKhau = sqlRr["MatKhau"].ToString();
                   if (!Convert.IsDBNull(sqlRr["MaQuyen"])) tk.MaQuyen = Convert.ToInt16(sqlRr["MaQuyen"]);
                   if (!Convert.IsDBNull(sqlRr["MaNhanVien"])) tk.MaNhanVien = sqlRr["MaNhanVien"].ToString();
                   if (!Convert.IsDBNull(sqlRr["Khoa"])) tk.Khoa = Convert.ToBoolean(sqlRr["Khoa"]);
                   kt = true;
               }
               dp.CloseConnection();
               if (kt) return tk;
               else return null;
           }
           else
           {
               return null;
           }
       }
    }
}
